<template>
	<view>
		<view class="noinfo" v-if="collect.length==0">无收藏</view>
		<view class="history" v-else>
			<block v-for="(item,index) in collect" :key="index">
				<view class="history-item" @click="lishitodetail(item.collectId,item.type,item.web)">
					<image class="his-img" :src="item.picture" v-if="item.picture"></image>
					<view :class="'his-title fontsize'+fontsizenub">{{item.title}}</view>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
	import {common} from '@/common/publish.js';
	import {mapState,mapMutations} from 'vuex';
	export default {
		data() {
			return {
				collect:[],
				uerInfo:''
			};
		},
		onLoad(event) {
			// uni.getStorage({
			// 	key:'uerInfo',
			// 	success(res){
			// 		that.uerInfo = res.data;
			// 		that.getlist(that.uerInfo.unionId)
			// 	}
			// })
			let unionId = uni.getStorageSync('unionId')
			this.getlist(unionId)
		},
		methods:{
			getlist(val){
				uni.request({
					url: common.csurl+'/api/collect/collectList.json', 
					data:{unionId:val},
					method:'GET',
					dataType:'json',
					success: (res) => {
						//console.log(JSON.stringify(res.data))
						this.collect = res.data;
					}
				});
			},
			lishitodetail(id,who,isweb){
				if(isweb){
					uni.navigateTo({
						url: '/pages/webview/webview?type='+ who +'&id='+id
					});
				}else{
					uni.navigateTo({
						url: '/pages/xq/xq?type='+ who +'&id='+id
					});
				}
			}
		},
		computed:{
			...mapState(['fontsizenub'])
		}
	}
</script>

<style lang="scss">
	@import '@/common/publish.scss';
	@include fontsizefn(".his-title",30upx);
	page{
		background-color: $bgcolor;
	}
	.noinfo{
		text-align:center;
		font-size:34upx;
		margin-top:200upx;
		color:$titlecolor;
	}
	.history{
		padding:0 24upx;
		background:#fff;
		margin-top:24upx 0;
	}
	.history-item{
		border-bottom:1px solid #ccc;
		padding:20upx 0;
		display: flex;
		flex-direction:row;
		flex-wrap:nowrap ;
		justify-content:flex-start;
		align-items:flex-start;
	}
	.his-img{
		width:240upx;
		height:135upx;
		margin-right:20upx;
		vertical-align:middle;
	}
	.his-title{
		flex:1;
		line-height:50upx;
		height:100upx;
		vertical-align:middle;
		color:$titlecolor;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}
</style>
